package com.skycode5.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private String FileName;
    private int DBType;
    private Connection conn;
    private String MySQLDriver;
    private String MySQLURL;
    public DBConnection(){
        conn=null;
    }
    public Connection getConn(){
        DBType = 1;
        switch (DBType){
            case 1:
                return (getConnToMySql());
                default:
                    return null;
        }
    }
    public Connection getConnToMySql() {
        try {
            MySQLDriver = "com.mysql.CJ.jdbc.Driver";
            MySQLURL = "jdbc:mysql://localhost:3306/sky5" + "?user=root&password=root&useUnicode=true" + "&characterEncoding=utf-8";
            Class.forName(MySQLDriver);
            conn = DriverManager.getConnection(MySQLURL);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }
}